package com.sikaryofficial.workbench.domain.mapping;

import com.sikaryofficial.system.api.domain.order.OrderItemVO;
import com.sikaryofficial.workbench.domain.dto.req.order.OrderDataSyncDetail;
import com.sikaryofficial.workbench.domain.dto.req.order.OrderItemReq;
import com.sikaryofficial.workbench.domain.dto.resp.order.OrderItemDTO;
import com.sikaryofficial.workbench.domain.entity.OrderItem;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author : wuweihong
 * @desc : TODO  请填写你的功能描述
 * @date : 2024-09-25
 */
@Mapper
public interface OrderItemMapping {

    OrderItemMapping INSTANCE = Mappers.getMapper(OrderItemMapping.class);

    /**
     * 实体映射req
     * @param req
     * @return
     */
    OrderItem coverToReq(OrderItemReq req);

    /**
     * 实体集合映射req
     * @param req
     * @return
     */
    List<OrderItem> coverListToReq(List<OrderItemReq> req);

    /**
     * 实体映射resp
     * @param orderItem
     * @return
     */
    OrderItemDTO coverToResp(OrderItem orderItem);

    /**
     * 实体集合映射resp
     * @param orderItem
     * @return
     */
    List<OrderItemDTO> coverListToResp(List<OrderItem> orderItem);

    /**
     * 实体集合映射entity
     * @param orderItemDTO
     * @return
     */
    OrderItem coverToEntity(OrderItemDTO orderItemDTO);

    OrderItemVO coverItemToVO(OrderItem orderItem);

    List<OrderItemVO> coverItemListToVO(List<OrderItem> orderItems);

    @Mapping(target = "unitPrice", source = "currentPrice")
    @Mapping(target = "totalPrice", source = "taxIncludeTotalPrice")
    OrderItem convertToEntity(OrderDataSyncDetail orderDataSyncDetail);
    List<OrderItem> convertToEntity(List<OrderDataSyncDetail> orderDataSyncDetails);
}
